package winTime.process;

import java.io.FileWriter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import winTime.Start;
import winTime.vo.TickKLine;

public class Write2File extends Thread{
	private static final Logger log=LoggerFactory.getLogger(Write2File.class);
	private static final String p="|";
	@Override
	public void run(){
		log.trace("Write2File start");
		FileWriter fw=null;
		int wait = 10000;
		try {
			Thread.sleep(wait);
			fw = new FileWriter("c:\\SecondTick"+Start.dateTag+".txt"); 
			for(TickKLine tk : Start.td){
				fw.write(p+Start.dateTag+p+tk.getCtime()+p+tk.getoPrice()+p+tk.gethPrice()+p+
						tk.getlPrice()+p+tk.getcPrice()+p+tk.getsQty()+p+tk.getCnt()+p+tk.getQtyPrice()+"|\n");
			}
			if(fw!=null){
				try{
					fw.close();
					fw=null;
				}catch(Exception e){}
			}
		} catch (Exception e) {
			log.error("error:{}",e);
		}
		log.trace("Write2File end");
	}
}
